<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>创建对象之构造函数</title>
</head>
<body>
    
    <script>
        
        function Person (name,age) {
            this.name = name;
            this.age = age;
            this.sayName = function () {
                alert(this.name);
            } 
        }

        let person = new Person('wang',27);

        person.sayName();

        //  在另一个作用域中调用怎么办呢？  -> call apply

        const obj = {
            name: 'he',
            age: 28
        }

        person.sayName.call(obj);

        
    </script>
</body>
</html>